//
// OpenTemplate
// Copyright (c) 2006
// by OpenArrow Software ( http://www.openarrow.com )
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions 
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
// DEALINGS IN THE SOFTWARE.
//

using System;
using OpenArrow.Templating.Properties;
using OpenArrow.Templating.Parsing;
using System.CodeDom;

namespace OpenArrow.Templating.Directives
{
    /// <summary>
    /// Utility base class for implementing directives
    /// <seealso cref="OpenArrow.Templating.Directives.IDirective"/>
    /// </summary>
    public class DirectiveBase : IDirective
    {
        private int lineNo;

        #region IDirective Members

        /// <summary>
        /// Gets or sets the line number on which the directive is located
        /// <seealso cref="OpenArrow.Templating.Directives.IDirective"/>
        /// </summary>
        /// <remarks>This property can be used for Error Reporting as well as the generation of Line Pragmas in the generated source</remarks>
        public int LineNumber
        {
            get { return lineNo; }
            set { lineNo = value; }
        }

        /// <summary>
        /// Executes the Directive in the specified <see cref="OpenArrow.Templating.Directives.DirectiveContext"/>
        /// <seealso cref="OpenArrow.Templating.Directives.IDirective"/>
        /// </summary>
        /// <param name="context">Context information for the execution of the directive</param>
        /// <exception cref="OpenArrow.Templating.ActionProblemsException">A large number of errors occurred in the operation and it had to be aborted</exception>
        /// <exception cref="ArgumentNullException"><paramref name="context"/> is <see langword="null"/></exception>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.String.Format(System.String,System.Object)"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.ArgumentNullException.#ctor(System.String,System.String)")]
        public virtual void Execute(DirectiveContext context)
        {
            if (context == null)
                throw new ArgumentNullException(String.Format(Resources.Exception_ArgIsNull, "context"), "context");
        }

        #endregion
    }
}
